package com.micmac.customer
{
	import com.micmac.customer.interfaces.ICustomerModule;
	import com.micmac.customer.interfaces.ICustomerService;
	import com.micmac.customer.model.CorpModel;
	import com.micmac.customer.model.OrgModel;
	import com.micmac.customer.model.PackageModel;
	import com.micmac.customer.model.PricingModel;
	import com.micmac.customer.model.ProductModel;
	import com.micmac.customer.model.SalesProcessModel;
	import com.micmac.customer.model.UserModel;
	import com.micmac.customer.service.CustomerService;
	import com.micmac.customer.view.CorporationView;
	import com.micmac.customer.view.CustomerPageView;
	import com.micmac.customer.view.MarketView;
	import com.micmac.customer.view.OrganisationView;
	import com.micmac.customer.view.PackageView;
	import com.micmac.customer.view.PricingView;
	import com.micmac.customer.view.ProductView;
	import com.micmac.customer.view.RegionView;
	import com.micmac.customer.view.SalesProcessView;
	import com.micmac.customer.view.UserView;
	import com.micmac.customer.view.mediator.CorparationViewMediator;
	import com.micmac.customer.view.mediator.CustomerPageViewMediator;
	import com.micmac.customer.view.mediator.MarketViewMediator;
	import com.micmac.customer.view.mediator.OrganisationViewMediator;
	import com.micmac.customer.view.mediator.PackageViewMediator;
	import com.micmac.customer.view.mediator.PricingViewMediator;
	import com.micmac.customer.view.mediator.ProductViewMediator;
	import com.micmac.customer.view.mediator.RegionViewMediator;
	import com.micmac.customer.view.mediator.SalesProcessViewMediator;
	import com.micmac.customer.view.mediator.UserViewMediator;
	
	import flash.display.DisplayObjectContainer;
	import flash.system.ApplicationDomain;
	
	import org.robotlegs.core.IInjector;
	import org.robotlegs.mvcs.Context;
	import org.robotlegs.utilities.modular.mvcs.ModuleContext;
	
	public class CustomerContext extends ModuleContext
	{
		
		public function CustomerContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true, parentInjector:IInjector=null, applicationDomain:ApplicationDomain=null) 
		{
			super(contextView, autoStartup, parentInjector, applicationDomain);
		}
		override public function startup():void
		{
			
			injector.mapClass(CustomerPageView,CustomerPageView);
			mediatorMap.mapView(CustomerPageView,CustomerPageViewMediator);
			
			injector.mapClass(CorporationView,CorporationView);
			mediatorMap.mapView(CorporationView,CorparationViewMediator);
			injector.mapSingleton(CorpModel);
			
			injector.mapClass(OrganisationView,OrganisationView);
			mediatorMap.mapView(OrganisationView,OrganisationViewMediator);
			injector.mapSingleton(OrgModel);
			
			injector.mapClass(RegionView,RegionView);
			mediatorMap.mapView(RegionView,RegionViewMediator);
			
			injector.mapClass(MarketView,MarketView);
			mediatorMap.mapView(MarketView,MarketViewMediator);
			
			injector.mapClass(UserView,UserView);
			mediatorMap.mapView(UserView,UserViewMediator);
			injector.mapSingleton(UserModel);
			
			injector.mapClass(PackageView,PackageView);
			mediatorMap.mapView(PackageView,PackageViewMediator);
			injector.mapSingleton(PackageModel);
			
			
			injector.mapClass(ProductView,ProductView);
			mediatorMap.mapView(ProductView,ProductViewMediator);
			injector.mapSingleton(ProductModel);
			
			injector.mapClass(PricingView,PricingView);
			mediatorMap.mapView(PricingView,PricingViewMediator);
			injector.mapSingleton(PricingModel);
			
			injector.mapClass(SalesProcessView,SalesProcessView);
			mediatorMap.mapView(SalesProcessView,SalesProcessViewMediator);
			injector.mapSingleton(SalesProcessModel);
			
			injector.mapSingletonOf(ICustomerService,CustomerService);

			viewMap.mapType(ICustomerModule);

			super.startup();
		}
		
		override public function dispose():void {
			mediatorMap.removeMediatorByView(contextView);
			super.dispose();
		}
	}
}